home *** CD-ROM | disk | FTP | other *** search
- /**************************
- AERoutines.c
- **************************/
-
- #include "extern.h"
- #include "AppleEvents.h"
- #include "Balloons.h"
- #include "Folders.h"
- #include "GestaltEqu.h"
- #include "Packages.h"
- #include "Traps.h"
-
-
- void DoAEInstallation( void );
- pascal OSErr HandleCreate( AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon );
- void DoHandleAERequest( FSSpec theSpec );
- OSErr DoRequiredCheck( AppleEvent *theAppleEvent );
-
- const OSType kTestEventClass = 'asd9';
- const OSType kCreateEventId = 'newf';
-
-
- /**************************
- DoAEInstallation
- **************************/
-
- void DoAEInstallation( void )
- {
- AEInstallEventHandler( kTestEventClass, kCreateEventId,
- (AEEventHandlerProcPtr)HandleCreate, 0, false );
- }
-
-
- /**************************
- HandleCreate
- **************************/
-
- pascal OSErr HandleCreate( AppleEvent *theAppleEvent, AppleEvent *reply, long myRefCon )
- {
- long i, itemsInList;
- short theFileRefNum, theCount;
- AEDescList docList;
- AEKeyword theKeyword;
- DescType typeCode;
- FInfo theFInfo;
- FSSpec theFSS;
- OSErr theErr;
- SFTypeList theTypeList;
- Size actualSize;
-
- theErr = AEGetParamDesc( theAppleEvent, keyDirectObject, typeAEList, &docList );
- if ( theErr )
- return ( theErr );
-
- theErr = DoRequiredCheck( theAppleEvent );
- if ( theErr )
- return ( theErr );
-
- theErr = AECountItems( &docList, &itemsInList );
- if ( theErr )
- return ( theErr );
-
- for ( i = 1; i <= itemsInList; i++ )
- {
- theErr = AEGetNthPtr( &docList, i, typeFSS, &theKeyword, &typeCode, ( Ptr )&theFSS, sizeof( FSSpec ), &actualSize );
- if ( theErr )
- return ( theErr );
-
- FSpGetFInfo( &theFSS, &theFInfo );
- DoHandleAERequest( theFSS );
- }
-
- return ( errAEEventNotHandled );
- }
-
-
- /**************************
- DoHandleAERequest
- **************************/
-
- void DoHandleAERequest( FSSpec theSpec )
- {
- short theCount, i, j;
- short tempVRefNum;
- long tempParID;
- FInfo theFInfo;
- OSErr theErr;
- OSType tempFileType;
- StringPtr tempStringPtr;
-
- tempStringPtr = ( StringPtr )NewPtrClear( STRING_LENGTH + 1 );
-
- if ( tempStringPtr == NIL )
- return;
-
- // Save the values.
- tempVRefNum = theSpec.vRefNum;
- tempParID = theSpec.parID;
-
- for ( theCount = 0; theCount <= theSpec.name[ 0 ]; theCount++ )
- tempStringPtr[ theCount ] = theSpec.name[ theCount ];
-
- FSpGetFInfo( &theSpec, &theFInfo );
-
- tempFileType = theFInfo.fdType;
-
- // Do something with incoming data...
-
- DisposPtr( ( Ptr )tempStringPtr );
-
- gRequestPending = false;
- }
-
-
- /**************************
- DoRequiredCheck
- **************************/
-
- OSErr DoRequiredCheck( AppleEvent *theAppleEvent )
- {
- OSErr theErr;
- DescType typeCode;
- Size actualSize;
-
- theErr = AEGetAttributePtr( theAppleEvent, keyMissedKeywordAttr, typeWildCard,
- &typeCode, NIL, NIL, &actualSize );
-
- if ( theErr == errAEDescNotFound )
- return ( noErr );
-
- if ( theErr == noErr )
- return ( errAEEventNotHandled );
-
- return ( theErr );
- }
-
-
-